﻿
using System ;
using System.Collections.Generic ;


namespace MskEdit.Msk.Model
{
    public class MskLineDictionary : Dictionary<string, int> 
    {
        private MskLineDictionary() {
        }
        
        public static MskLineDictionary From( string[] lines ) {
        
            MskLineDictionary newDictionary = new MskLineDictionary() ;
            
            if ( lines == null )
                return newDictionary ;
                
            for ( int i = 0 ; i < lines.Length ; ++i ) {
            
                MskLineKey lineKey = MskLineKey.TryFrom( lines[ i ], null ) ;
                if ( lineKey == null )
                    continue ;
                    
                string mskLineKeyAsString = lineKey.ToString() ;
                newDictionary[ mskLineKeyAsString ] = i ;
            }
            
            return newDictionary ;
        }
    }
}
